//
//  YCTranslatorViewController.m
//  XTranslator
//
//  Created by 唐可雄 on 17/2/18.
//  Copyright © 2017年 swustyc. All rights reserved.
//

#import "YCTranslatorViewController.h"

#import <Translator/Translator.h>

@interface YCTranslatorViewController ()

/**
 当前翻译器
 */
@property (nonatomic, strong) YCTranslator *curTranslator;

@end

@implementation YCTranslatorViewController

#pragma mark - ViewController LifeCycle

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do view setup here.
    
    [self translatorKindDidChoose:self.translatorKindMenuBtn];
}

#pragma mark - Action

/**
 点击转换按钮

 @param sender 转换按钮
 */
- (IBAction)translateBtnDidClick:(id)sender {
    self.toTextView.string = [self.curTranslator strFrom:self.fromTextView.string];
}

/**
 选择翻译器的类别

 @param sender 翻译器的类别菜单
 */
- (IBAction)translatorKindDidChoose:(id)sender {
    self.curTranslator = [self translatorOnChoice];
}

#pragma mark - Translator

- (YCTranslator *)translatorOnChoice {
    if (self.translatorKindMenuBtn.indexOfSelectedItem == 0) {
        return [[YCTranslatorUTF8_16ToChinese alloc] init];
    } else {
        return nil;
    }
}

@end
